package jdk8;

import java.io.File;
import java.util.function.Function;
//类实例方法引用。
public class TestClassInstanceMethodRef01 {
    public static void main(String[] args) {
        //1.传统方式
        Function<File,String> f1=new Function<File, String>() {
            @Override
            public String apply(File f) {
                return f.getAbsolutePath();
            }
        };
        System.out.println("f1 = " + f1.apply(new File("pom.xml")));

        //2.Lambal方式
        Function<File,String> f2=file -> file.getAbsolutePath();
        System.out.println("f2 = " + f2.apply(new File("pom.xml")));
        //3.类实例方法引用"类名::实例方法名"
        Function<File,String> f3=File::getAbsolutePath;
        System.out.println(f3.apply(new File("pom.xml")));
    }
}
